package common;

import java.io.Serializable;

public class CommandMessage extends AbstractMessage implements Serializable{
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 8163591408029211962L;
	public static final String ACKNOWLEDGE_MESSAGE = "ACK";
	public static final String LOGIN_MESSAGE = "LGN";
	public static final String CREATE_USER = "CRU";
	
	private String command;
	private Object[] params;
	
	/**
	 * Default constructor
	 */
	public CommandMessage() {
		command = "";
		params = null;
	}
	
	/**
	 * Constructor
	 * @param command Command string
	 * @param params Command parameters as objects array
	 */
	public CommandMessage(String command, Object[] params) {
		this.command = command;
		this.params = params;
	}
	
	/**
	 * Command getter
	 * @return Command
	 */
	public String getCommand() {
		return command;
	}
	
	/**
	 * Command setter
	 * @param command Command to set
	 */
	public void setCommand(String command) {
		this.command = command;
	}

	/**
	 * Command parameters getter
	 * @return Command parameters array
	 */
	public Object[] getParams() {
		return params;
	}
	
	/**
	 * Command parameters setter
	 * @param params Command parameters array
	 */
	public void setParams(Object[] params) {
		this.params = params;
	}
	
	/**
	 * Represent message as debug string
	 */
	@Override
	public String ToDebugMessage() {
		String ret = "Command: " + command;
		if (params != null && params.length > 0) {
			ret += " Parameters: ";
			for(Object o:params) {
				ret += o.toString() + ", ";
			}
		}
		return ret ;
	}

}
